#ifndef CHATWIDGET_H
#define CHATWIDGET_H
#pragma once
#include <QWidget>
#include "global.h"
#include "statewidget.h"
#include "userdata.h"
#include <QVector>
#include <QEvent>
#include <QMap>
#include <QListWidget>
namespace Ui {
class ChatWidget;
}

class ChatWidget : public QWidget
{
    Q_OBJECT

public:
    explicit ChatWidget(QWidget *parent = nullptr);
    ~ChatWidget();
    void ShowSearch(bool bsearch);

//    void mousePressEvent(QMouseEvent *event) override;
//    void mouseMoveEvent(QMouseEvent *event) override;
//    void mouseReleaseEvent(QMouseEvent *event) override;

protected:
    bool  eventFilter(QObject *watched, QEvent *event);
private:
    void ClearLabelState(StateWidget *lb);
    void AddLBGroup(StateWidget *lb);
    void handleGlobalMousePress(QMouseEvent *event);
    Ui::ChatWidget *ui;
    ChatUIMode _mode;
    ChatUIMode _state;
    bool _bLoading;
    void setStateBar();
    void setTitleBar();
    void setSearchBar();
    QRect _rect;
    bool _windowFlag;
    QVector<StateWidget*> _lb_list;
    QMap<int, QListWidgetItem*> _chat_items_added;
    void UpdateChatMsg(std::vector<std::shared_ptr<TextChatData> > msgdata);
    int _cur_chat_uid;
public slots:
    void SlotLoadingChatUser();

    void slot_side_chat();
    void slot_side_contact();
    void slot_text_changed();
    void SlotApplyFriend(std::shared_ptr<AddFriendApply> apply);
    void slotAddAuthFriend(std::shared_ptr<AuthInfo> auth_info);
    void SlotAuthRsp(std::shared_ptr<AuthRsp> auth_rsp);
    void SlotTextChatMsg(std::shared_ptr<TextChatMsg> msg);

};

#endif // CHATWIDGET_H
